package automaton;

import java.util.ArrayList;

import dk.brics.automaton.Automaton;

public class AutomatonUtils {
	
	
	
	/**
	 * this method gets an automaton with finite language and returns an automaton
	 * which composed of 2 states, initial and accept and the transitions are
	 * the words from the original automaton
	 * 
	 * for example: the accept route: s0 - s1 - s2 - s3 (s3 accepts)
	 * 									 \    \    *
	 * will convert to s0   -   s1 (s1 accepts)
	 * 						\\*
	 * @param A
	 * @return
	 */
	public static Automaton StableAutomaton(Automaton A)
	{
		ArrayList<Automaton> wordAutomatons = new ArrayList<Automaton>();
		
		for(String word:A.getFiniteStrings())
		{
			wordAutomatons.add(Automaton.makeString(word));
		}
		
		return Automaton.union(wordAutomatons);
	}
}
